package com.example.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

// 订单确认页需要用的数据

public class OrderConfirmVo {
    //收货地址 ums_member_receive_address
    @Getter
    @Setter
    private List<MemberAddressVo> address;
    //所有选中的购物项
    @Getter
    @Setter
    private List<OrderItemVo> items;
    // 发票记录 不做

    // 优惠卷信息，只做会员积分
    @Getter
    @Setter
    private Integer integration;




    public BigDecimal getTotal() {
        total=new BigDecimal("0");
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount()));
                total = total.add(multiply);
            }
        }
        return total;

    }
    private BigDecimal total=new BigDecimal("0"); //订单总额


    public BigDecimal getPayPrice() {
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount()));
                payPrice = payPrice.add(multiply);
            }
        }
        return payPrice;
    }

    private BigDecimal payPrice=new BigDecimal("0"); //应付总额



    //订单放重复令牌，防重复提交
    @Getter
    @Setter
   private String orderToken;
    private  Integer count=0;
    public Integer getCount() {

        if (items != null) {
            for (OrderItemVo item : items) {
                count+=item.getCount();
            }
        }
        return  count;
    }
    @Getter @Setter
    Map<Long,Boolean> stocks;


}
